/*
 * @lc app=leetcode.cn id=389 lang=typescript
 *
 * [389] 找不同
 */

// @lc code=start
function findTheDifference(s: string, t: string): string {
    const cache = new Map<string, number>();
    t.split("").forEach((i) => {
        cache.set(i, (cache.get(i) || 0) + 1);
    });
    s.split("").forEach((i) => {
        cache.set(i, (cache.get(i) || 0) - 1);
    });
    for (const [key, val] of cache.entries()) {
        if (val === 1) return key;
    }
    return "";
}
// @lc code=end
